package com.lyz.util;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
import java.net.Socket;

import org.apache.log4j.Logger;

public class CloseUtil {
	
	private static final Logger logger = Logger.getLogger(CloseUtil.class);
	
	
	public static void closeInputStream(InputStream is){
		
		try {
			if(is != null){
				is.close();
				is = null;
			}
		} catch (IOException e) {
			logger.warn("error to close inputstream", e);
		}
	}
	
	public static void closeOutputStream(OutputStream os){
		try {
			if(os != null){
				os.close();
				os = null;
			}
		} catch (IOException e) {
			logger.warn("error to close outputstream", e);
		}
	}
	
	public static void closeReader(Reader reader){
		try {
			if(reader != null){
				reader.close();
				reader = null;
			}
		} catch (IOException e) {
			logger.warn("error to close reader", e);
		}
	}
	
	public static void closeSocket(Socket socket){
		try {
			if(socket != null){
				socket.close();
				socket = null;
			}
		} catch (IOException e) {
			logger.warn("error to close socket", e);
		}
	}
	
}
